package 简单工厂模式;

import java.util.HashMap;

public class TVFactory {
    public static HashMap<String, TV> hashMap = new HashMap<>();
    static{
        hashMap.put("hair", new HairTV());
        hashMap.put("TCL", new TCLTV());
    }
    public static TV productTV(String type) {


        TV tv = null;
        if ("hair".equals(type)) {
            tv = hashMap.get("hair");
            tv.play();
        } else if ("TCL".equals(type)) {
            tv = hashMap.get("TCL");
            tv.play();
        } else {
            System.out.println("无法生产");
        }
        return tv;
    }
}
